package com.cx.dao;

import com.cx.pojo.Comment;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;


public interface CommentMapper {

    //    添加评论
    @Insert("INSERT INTO `t_comment`(`user_id`,`pl_content`,`pl_time`) VALUES(#{id},#{content},now());")
    public void addComment(@Param("id") Integer id, @Param("content") String content);

    //    添加评论回复
    @Insert("INSERT INTO `t_comment`(`user_id`,`pl_content`,`pid`) VALUES(#{id},#{content},#{pid});")
    public void addCommentReply(@Param("id") Integer userId, @Param("content") String content, @Param("pid") Integer pid);


    //    根据id删除指定的评论
    @Delete("DELETE FROM `t_comment`  WHERE id = #{id};")
    public void deleteCommentById(Integer id);


    //根据用户ID查询全部评论
    @Select("SELECT `id`,`user_id` userId,`pl_content` plContent,`pl_time` plTime ,pid FROM `t_comment` WHERE `user_id` = #{userId};")
    public List<Comment> getCommentAllById(Integer id);

    //    查询全部评论
    @Select("SELECT `id`,`user_id` userId,`pl_content` plContent,`pl_time` plTime ,pid FROM `t_comment` WHERE `pid` IS NULL;")
    public List<Comment> getCommentAll();

    //根据PID查询评论
    @Select("SELECT `id`,`user_id` userId,`pl_content` plContent,`pl_time` plTime ,pid FROM `t_comment` WHERE `pid` = #{pid};")
    public List<Comment> getCommentById(Integer pid);

    /*===========================================*/

//    //    根据俱乐部id发布资源
//    @Insert("INSERT INTO `club_resource`(`club_id`,`resource_name`,`resource`)VALUES (#{id},#{contentName}#{content});")
//    public void getAllClubResourceById( @Param("id") Integer id, @Param("contentName") String contentName, @Param("content") String content);
//
//    //根据资源id删除资源
//    @Delete("DELETE FROM club_resource WHERE resource_id = #{id}")
//    public void getDeleteClubResourceById(Integer id);
//
//    //    根据俱乐部id查询全部文章
//    @Select("SELECT * FROM club_resource WHERE Club_ID = #{id}")
//    public List<String> getClubByIdList(Integer id);
//
//    //    根据俱乐部id查询文章内容
//    @Select("SELECT * FROM club_resource WHERE Club_ID = #{id}")
//    public String getClubById(Integer id);

}